/**
 * Created by Luxh on 2014/7/14.
 */

/**
 * 根据parent_code查询字典数据
 * @param parent_code
 * @returns {Array}
 */
function getDict(parent_code) {
    var dict = [];
    var params = {};
    if(parent_code){
        params.parent_code = parent_code;
    }
    Ext.Ajax.request({
        url: '/dict/list',
        params : params,
        method : 'get',
        async:false,
        success: function(response, opts) {
            var result =  Ext.decode(response.responseText);
            Ext.Array.forEach(result,function(obj,index){
                if(obj.key_code){
                   dict[obj.key_code] = obj.key_name; 
                }                
            });
        },
        failure: function(response, opts) {

        }
    });
    return dict;
}

function getDictSimple(){    
    var dicts = null;
    Ext.Ajax.request({
        async:false,
        url: '/dict/list_simple',
        method : 'GET',
        success: function(response, opts) {
            var data = Ext.decode(response.responseText);
            if(data) {
                dicts = data;
            }
        },
        failure: function(response, opts) {
        }
    });
    return dicts;
}